<!DOCTYPE html>
<html lang="zh_CN">
<head>
  <meta charset="UTF-8">
  <title>绝密文件</title>
</head>
<body>
  <h1>绝密文件</h1>
  <script>
    function getSecret(file, secretPassword) {
        file.opened = file.opened + 1;
        if (secretPassword == file.password) {
            return file.contents;
        }
        else {
            return "密码错误！禁止查看信息！";
        }
    }
    function setSecret(file, secretPassword, secret) {
        if (secretPassword == file.password) {
            file.opened = 0;
            file.contents = secret;
        }
    }

    var superSecretFile = {
        level:"classified",
        opened:0,
        password:2,
        contents:"Evel 博士的下一个会议在Detroit."
    }
    var secret = getSecret(superSecretFile, 2);
    console.log(secret);

    setSecret(superSecretFile, 2, "Evel 博士的下一场会议在Philadelphia.");
    secret = getSecret(superSecretFile, 2);
    console.log(secret);
  </script>
</body>
</html>